<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

	<ui:define name="body">

		<h:form id="articuloSearch" styleClass="edit">

			<rich:simpleTogglePanel label="Filtros de Busqueda" switchType="ajax">

				<s:decorate template="layout/display.xhtml">
					<ui:define name="label">Descripcion</ui:define>
					<h:inputText id="descripcion"
						value="#{articuloList.articulo.descripcion}" />
				</s:decorate>

			</rich:simpleTogglePanel>

			<div class="actionButtons"><h:commandButton id="search"
				value="Buscar" action="/ArticuloList.xhtml" /> <s:button id="reset"
				value="Limpiar Busqueda" includePageParams="false" /></div>

		</h:form>

		<rich:panel>
			<f:facet name="header">Resultados</f:facet>
			<div class="results" id="articuloList"><h:outputText
				value="No hay articulos que coincidan con la busqueda"
				rendered="#{empty articuloList.resultListParaSeleccion}" /> <rich:dataTable
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				id="articuloList" var="_articulo" value="#{articuloList.resultListParaSeleccion}"
				rendered="#{not empty articuloList.resultListParaSeleccion}">

				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{articuloList}" />
							<ui:param name="propertyLabel" value="Codigo articulo" />
							<ui:param name="propertyPath" value="articulo.codigoArticulo" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{formateadorDeCodigos.formatearCodigo(_articulo.codigoArticulo,5)}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{articuloList}" />
							<ui:param name="propertyLabel" value="Descripcion" />
							<ui:param name="propertyPath" value="articulo.descripcion" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_articulo.descripcion}" />
				</h:column>

				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{articuloList}" />
							<ui:param name="propertyLabel" value="Codigo de Proveedor" />
							<ui:param name="propertyPath"
								value="articulo.proveedor.idProveedor" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_articulo.proveedor.codigoFabricante}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<ui:include src="layout/sort.xhtml">
							<ui:param name="entityList" value="#{articuloList}" />
							<ui:param name="propertyLabel" value="Tipo de articulo" />
							<ui:param name="propertyPath" value="articulo.tipoArticulo" />
						</ui:include>
					</f:facet>
					<h:outputText value="#{_articulo.tipoArticulo}" />
				</h:column>
				<rich:column styleClass="action">
					<f:facet name="header">Accion</f:facet>
					<s:link view="/#{empty from ? 'Articulo' : from}.xhtml"
						value="#{empty from ? 'Ver' : 'Seleccionar'}"
						propagation="#{empty from ? 'none' : 'default'}"
						id="articuloViewId">
						<f:param name="articuloIdArticulo" value="#{_articulo.idArticulo}" />
					</s:link>
            #{' '}
            <s:link view="/ArticuloEdit.xhtml" value="Editar"
						propagation="none" id="articuloEdit" rendered="#{empty from}">
						<f:param name="articuloIdArticulo" value="#{_articulo.idArticulo}" />
					</s:link>
				</rich:column>
			</rich:dataTable></div>
		</rich:panel>

		<div class="tableControl"><s:link view="/ArticuloList.xhtml"
			rendered="#{articuloList.previousExists}"
			value="#{messages.left}#{messages.left} Primera pagina" id="firstPage">
			<f:param name="firstResult" value="0" />
		</s:link> <s:link view="/ArticuloList.xhtml"
			rendered="#{articuloList.previousExists}"
			value="#{messages.left} Pagina anterior" id="previousPage">
			<f:param name="firstResult"
				value="#{articuloList.previousFirstResult}" />
		</s:link> <s:link view="/ArticuloList.xhtml"
			rendered="#{articuloList.nextExists}"
			value="Pagina siguiente #{messages.right}" id="nextPage">
			<f:param name="firstResult" value="#{articuloList.nextFirstResult}" />
		</s:link> <s:link view="/ArticuloList.xhtml"
			rendered="#{articuloList.nextExists}"
			value="Ultima pagina #{messages.right}#{messages.right}" id="lastPage">
			<f:param name="firstResult" value="#{articuloList.lastFirstResult}" />
		</s:link></div>

		<s:button view="/#{from}.xhtml" id="cancel" propagation="none"
			rendered="#{not empty from}" value="Cancelar">
		</s:button>

		<s:div styleClass="actionButtons" rendered="#{empty from}">
			<s:button view="/ArticuloEdit.xhtml" id="create" propagation="none"
				value="Crear articulo">
				<f:param name="articuloIdArticulo" />
			</s:button>
		</s:div>

	</ui:define>

</ui:composition>
